package com.label.Config.MyBatis;

import java.util.Date;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", new Date(), metaObject);
        this.setFieldValByName("creatTime", new Date(), metaObject);
        this.setFieldValByName("updateTime", new Date(), metaObject);
        this.setFieldValByName("states",0,metaObject);
        this.setFieldValByName("state","1",metaObject);
        this.setFieldValByName("time",new Date(),metaObject);
        this.setFieldValByName("activeTime",new Date(),metaObject);
        this.setFieldValByName("helpDate",new Date(),metaObject);

    }
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime", new Date(), metaObject);
        this.setFieldValByName("time",new Date(),metaObject);
        this.setFieldValByName("states","1",metaObject);
        this.setFieldValByName("activeTime",new Date(),metaObject);
    }
}
